package com.whw.fy.controller;


import com.whw.fy.entity.Activ;
import com.whw.fy.entity.Message;
import com.whw.fy.entity.Record;
import com.whw.fy.service.ActivService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.text.ParseException;
import java.text.SimpleDateFormat;

@Api(tags = "教学活动评测模块")
@RestController
@RequestMapping("/api/activ")
public class ActivController {

    @Resource
    ActivService activService;


    @ApiOperation(value = "添加教学活动评测")
    @PostMapping("/insert")
    public Message insert(Activ activ)throws ParseException {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        if (activ.getActivCreatetime()!=null)
            activ.setActivCreatetime(simpleDateFormat.parse(activ.getActivCreateTimeToString()));
        return activService.insertSelective(activ);
    }

    @ApiOperation(value = "删除教学活动评测记录")
    @DeleteMapping("/")
    public Message delete(int activId) {
        return activService.deleteByPrimaryKey(activId);
    }

    @ApiOperation(value = "修改教学活动评测记录")
    @PutMapping("/")
    public Message update(Activ activ) {
        return activService.updateByPrimaryKeySelective(activ);
    }

    @ApiOperation(value = "根据听课id查找教学活动评测记录")
    @GetMapping("/one")
    public Message selectByPrimaryKey(int activId){
        return activService.selectByPrimaryKey(activId);
    }

    @ApiOperation(value = "获得所有听课记录")
    @GetMapping("/all")
    public Message selectAll(){
        return activService.selectAll();
    }




}
